<template>
  <div id="table">
    <el-form label-width="10px" class="form-container" :model="postForm" ref="postForm">
    <el-row>
      <el-input v-model="postForm.deviceCode" style="width:200px"placeholder="请输入设备编号" ></el-input>
      <el-button type="primary" @click="searchDevice">搜索设备</el-button>
      <el-button type="primary" @click="deleteDevice">删除设备</el-button>
      <el-button type="primary" @click="update(postForm.deviceCode)">修改设备</el-button>
      <el-button type="primary" @click="addDevice">添加设备</el-button>
      <el-button type="danger" @click="show">所有设备</el-button>
    </el-row>
    <el-table
      :data="ManufactureProTable"
      border style="width: 100%">
      <el-table-column
        prop="deviceCode"
        label="设备id">
      </el-table-column>
      <el-table-column
        prop="processStages"
        label="工艺流程">
      </el-table-column>
      <el-table-column
        prop="workPressure"
        label="工作压力">
      </el-table-column>
      <el-table-column
        prop="workTemperature"
        label="工作温度">
      </el-table-column>
      <el-table-column
        prop="workMedium"
        label="工作介质">
      </el-table-column>
      <el-table-column
        prop="time"
        label="时间">
      </el-table-column>
      <el-table-column
        prop="realTimeTemperature"
        label="实时温度">
      </el-table-column>
      <el-table-column
        prop="materialLevel"
        label="料位">
      </el-table-column>
    </el-table>
</el-form>
  </div>
</template>

<script>
  import { req } from '@/api/base/BaseApi'
  const defaultForm = {
    deviceCode: undefined,
    workPressure: undefined,
    workTemperature: undefined,
    workMedium: undefined,
    processStages: undefined,
    time: undefined,
    realTimeTemperature: undefined,
    materialLevel: undefined
  }
  export default {
    name: 'index',
    data() {
      return {
        table1: [],
        ManufactureProTable: [],
        postForm: Object.assign({},defaultForm),
      }
    },
    mounted: function() {
      this.show()
      this.postForm = Object.assign({}, defaultForm)
    },
    methods: {
      get: function() {
      },
      show() {//显示所有工艺流程信息
        req('/coketower-service/manufactureData/allList', 'GET', '').then(response => {
          this.ManufactureProTable = response.data
          console.log(response.data)
          console.log(this.ManufactureProTable[0])
        }).catch(() => console.log('page request error'))
      },
      searchDevice(){//根据设备编号搜索
        req('/coketower-service/manufactureData/', 'GET', this.postForm).then(response => {
          this.ManufactureProTable = response.data
        }).catch(() => console.log('page request error'))
      },
      deleteDevice(){//根据设备编号删除
        req('/coketower-service/manufactureData/' + this.postForm.deviceCode, 'DELETE').then(response => {
          this.show()
        }).catch(() => console.log('page request error'))
        this.$message('删除成功！')
      },
      addDevice(){//添加新设备
        this.$router.replace({path: '/otherdata/Manufacturingprocess/addDevice'})
      },
      update(id){//修改设备
      this.$router.push({path:'/otherdata/Manufacturingprocess/updateDevice',query:{id:id}})
      },

    }
  }
</script>

<style scoped>

</style>
